﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ClimateControl.Infrastructure.Extensions
{
    public static class DateTimeExtensions
    {
        #region Supporting Classes

        public class TimeComparison
        {
            #region Fields

            private double length;
            private DateTime dateTime;

            #endregion Fields

            #region Constructor

            public TimeComparison(DateTime dateTime, double length)
            {
                this.length = length;
                this.dateTime = dateTime;
            }

            #endregion Constructor

            #region Properties

            public bool Minutes
            {
                get { return dateTime > DateTime.Now.AddMinutes(-length); }
            }

            public bool Hours
            {
                get { return dateTime > DateTime.Now.AddHours(-length); }
            }

            public bool Days
            {
                get { return dateTime > DateTime.Now.AddDays(-length); }
            }

            #endregion Properties
        }

        #endregion Supporting Classes

        #region Methods

        public static TimeComparison IsInTheLast(this DateTime dateTime, double length)
        {
            return new TimeComparison(dateTime, length);
        }

        #endregion Methods
    }
}
